package com.demo.apparel.controller.uniapp;
import com.demo.apparel.entity.Ana;
import com.demo.apparel.service.uniapp.WxAnaService;
import com.demo.apparel.service.web.AnaService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Random;

@RestController
@RequestMapping("/wx/ana")
@Tag(name = "语录信息接口", description = "语录信息")
public class WxAnaController {

    @Autowired
    private WxAnaService wxAnaService;
    @GetMapping("/list")
    @Operation(summary = "获取语录信息")
    public Ana getRandomAna() {
        List<Ana> allList = wxAnaService.getAllAna();
        if (allList == null || allList.isEmpty()) {
            return null;
        }
        int randomIndex = new Random().nextInt(allList.size());
        return allList.get(randomIndex);
    }

}
